<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'mortgage.label', default: 'Mortgage')}"/>
    <title>房地产类押品</title>
    <style>
    .table>tbody>tr>td{
        vertical-align: middle;
    }
    @media screen and (min-width:1900px) and (max-width:1920px) {
        .flex{
            display: flex;justify-content: center;align-items: center;
        }
    }
    .select2-container .select2-choices .select2-search-field input,.select2-container .select2-choice,.select2-container .select2-choices{

        color: #999;
    }
    </style>
</head>

<body class="fixed-navbar fixed-sidebar">

<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right navFloatRight">
                <ol class="hbreadcrumb breadcrumb">
                    <li>
                        <span>CINDTATA PLS</span>
                    </li>
                    <li>
                        <span>房地产</span>
                    </li>
                </ol>
            </div>
        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <g:form method="POST" action="estatePendingIndex" class="form-horizontal" role="form" id="form" onsubmit="return text();">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit" onclick=""><i class="fa fa-search"></i> 查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                            <i class="fa fa-times"></i> 重置</button>
                    </div>
                    查询
                </div>
                    <div class="panel-body seach-group" id="bug1">
                    %{--第一行--}%

                    <input type="hidden" name="flag" value="${this.params?.flag}">
                    <input type="hidden" name="status" value="${this.params?.status}">
                    <div class="row ">
                        <div class="form-group col-sm-4">
                            <label for="city" class="col-sm-3 control-label">城市</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="city" id="city" from="${com.cindata.City.findAllByNameInList(new com.cindata.ComponentService().evaluate(com.cindata.Component.findByCode('showCity')), [sort: 'name', order: 'asc'])}"
                                          valueMessagePrefix="status" optionKey="zoneNumber" optionValue="name"
                                          value="${params?.city}"
                                          noSelection="${["-1": '请选择城市']}"/>
                                <input type="hidden" id="communityId" value="${params?.communityId}" name="communityId" />
                            </div>
                        </div>
                        <div class="form-group col-sm-4">
                            <label for="district" class="col-sm-3 control-label">行政区</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="district" id="district"
                                          from="${districtList}"
                                          valueMessagePrefix="status" optionKey="zoneNumber" optionValue="name"
                                          value="${params?.district}"
                                          noSelection="${["null": '请选择行政区']}"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-4">
                            <label class="col-sm-3 control-label">押品状态</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="estateStatus" id="estateStatus"
                                          from="${com.cindata.dictionary.EstateStatusDict.list()}"
                                          valueMessagePrefix="status" optionKey="id" optionValue="name"
                                          value="${params?.estateStatus}"
                                          noSelection="${["": '请选择押品状态']}"/>
                            </div>
                        </div>
                    </div>
                    %{--第二行--}%
                    <div class="row ">
                        <div class="form-group col-sm-4">
                            <label for="district" class="col-sm-3 control-label">押品编号</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="externalId" id="externalId" value="${params?.externalId}" placeholder="请输入押品编号">
                            </div>
                        </div>
                        <div class="form-group col-sm-4">
                            <label for="district" class="col-sm-3 control-label">押品名称</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="name" id="name" value="${params?.name}" placeholder="请输入押品名称">
                            </div>
                        </div>

                    </div>
                    %{--第三行--}%
                    <div class="row ">
                        <div class="form-group col-sm-4">
                            <label class="col-sm-3 control-label">房屋用途</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="buildingType" id="buildingType"
                                          from="${com.cindata.dictionary.BuildingTypeDict.listOrderById()}"
                                          valueMessagePrefix="status" optionKey="id" optionValue="name"
                                          value="${params?.buildingType}"
                                          noSelection="${["": '请选择房屋用途']}"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-4">
                            <label for="district" class="col-sm-3 control-label">房屋详细地址</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="sourceAddress" id="sourceAddress" value="${params?.sourceAddress}" placeholder="请输入房屋详细地址">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </g:form>
    </div>

    <div class="row">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    <!-- <button class="btn btn-warning2 btn-xs" type="submit" onclick="searchMap()"><i class="fa fa-map-marker"></i> 查看地图</button> -->
                    <sec:ifAllGranted roles="ROLE_CUSTOMER_MANAGER">
                        <g:link action="estateCreate" class="btn btn-info btn-xs"><i class="fa fa-plus"></i>新建</g:link>
                    </sec:ifAllGranted>
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                &nbsp;&nbsp;
            </div>

            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table cellpadding="1" cellspacing="1" class="table table-striped table-bordered table-hover text-center" id="esateTable">
                        <thead>
                            <tr>
                                <g:sortableColumn property="externalId" title="押品编号"   params="${params}"/>
                                <g:sortableColumn property="buildingType" title="房屋用途"    params="${params}"/>
                                <g:sortableColumn property="estateStatus" title="押品状态"   params="${params}"/>

                                <g:sortableColumn property="name" title="押品名称"    params="${params}"/>
                                <g:sortableColumn property="city" title="城市"    params="${params}"/>
                                <g:sortableColumn property="district" title="行政区"    params="${params}"/>
                                <g:sortableColumn property="fullName" title="抵押人名称"    params="${params}"/>
                                <g:sortableColumn property="sourceAddress" title="房屋详细地址"   params="${params}"/>
                                <g:sortableColumn property="sourceBuildArea" title="面积"   params="${params}"/>
                                <g:sortableColumn property="latestEvaluatePrice" title="最新评估价值"   params="${params}"/>
                                <g:sortableColumn property="latestEvaluateDate" title="最新评估日期"   params="${params}"/>
                                <g:sortableColumn property="registerFullName" title="登记人"   params="${params}"/>
                                <g:sortableColumn property="registerAccount" title="登记机构"    params="${params}"/>
                                <g:sortableColumn property="registerDate" title="登记日期"    params="${params}"/>
                            </tr>
                        </thead>
                        <tbody>
                            <g:each in="${collateralList}">
                                <tr>
                                    <td ><g:link style="color: #3498DB" action="estateShow" class="firstTd" id="${it?.id}">${it.externalId}</g:link></td>
                                    <td>${it?.estate?.buildingType?.name}</td>
                                    <td>${it?.estateStatus?.name}</td>
                                    <td>${it?.name}</td>
                                    <td>${it?.city?.name}</td>
                                    <td>${it?.district?.name}</td>
                                    <td>${it?.fullName}</td>
                                    <td>${it?.estate?.sourceAddress}</td>
                                    <td>${it?.estate?.buildArea}</td>
                                    <td>${it?.latestEvaluatePrice}</td>
                                    <td>
                                        <g:if test="${it?.latestEvaluateDate}">
                                            <g:formatDate date="${it?.latestEvaluateDate}" format="yyyy-MM-dd"></g:formatDate>
                                        </g:if>
                                    </td>
                                    <td>${it?.registerFullName}</td>
                                    <td>${it?.registerAccount}</td>
                                    <td>
                                        <g:if test="${it?.registerDate}">
                                            <g:formatDate date="${it?.registerDate}" format="yyyy-MM-dd"></g:formatDate>
                                        </g:if>
                                    </td>
                                </tr>
                            </g:each>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate action="estatePendingIndex" total="${collateralCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>
</div>

<g:javascript>

    function searchMap() {
        var city = $("#city").val();
        if(city=="-1"){
            toastr.error('请选择城市');
            return
        }
        window.location.href="/newMap/cluster?currentMap=clusterMap&city="+$("#city").val()+"&district="+$("#district").val()+"&communityId="+$("#communityId").val();
    }
    $(function () {
        $('#datepicker').datepicker({
            language: 'zh-CN'
        });
        $("#datepicker").on("changeDate", function(event) {
            $("#my_hidden_input").val(
                    $("#datepicker").datepicker('getFormattedDate')
            )
        });

        $('.input-group.date').datepicker({ });
        $('.input-daterange').datepicker({ });
        var flag;
        $("#city").bind("change", function(){
            if('${params.district}'== $("#district option:selected").val()&&flag!=true && '${params.district}' != '-1'){
                flag=true
                return
            }
            $("#district option").remove();
            $("#s2id_district span:first").html("请选择行政区");
            var city = $("#city").val()
            $("#district").append("<option value='-1' >请选择行政区</option>")
            if(city=='-1'){
                return
            }
            $.ajax({
                url: "/estate/districtList",
                type: "POST",
                data: {'city': city} ,
                success: function(result){
                    for(var i=0; i < result.districtList.length; i++){
                        $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
                    }
                }
            });
        });
        $("#city").change();
    });

    //重置按钮
    $("#resetBtn").click(function () {
        $("#communityId").val("");
        $("#s2id_city span:first").html("请选择城市");
        $("#city").val("");
        $("#s2id_district span:first").html("请选择行政区");
        $("#district").val("");
        $('#s2id_estateStatus span:first').html('请选择押品状态');
        $('#estateStatus').val('');
        $("#sourceAddress").val("");
        $("#name").val("");
        $('#s2id_risk span:first').html('请选择押品风险');
        $('#risk').val("");
        $('#s2id_mortgageStatus span:first').html('请选择贷款状态');
        $('#mortgageStatus').val("");
        $('#s2id_buildingType span:first').html('请选择房屋用途');
        $('#buildingType').val("");
        $("#buildAreaStart").val("");
        $("#buildAreaEnd").val("");
        $('#s2id_cashability span:first').html('请选择变现能力');
        $("#cashability").val("");
        $("#externalId").val("");
        /*$('#s2id_stage span:first').html('请选择押品阶段');
        $("#stage").val("");*/
    });

</g:javascript>

</body>
</html>
